import vim
import sys
import glob
import os

import ts_vim

__gui_suffix = 'cli'
if ts_vim.is_gui_running:
	__gui_suffix = 'gui'

__last_file = 'last_%s' % __gui_suffix
__current_file = 'current_%s' % __gui_suffix

def session_save_last():
	ts_vim.save_session( __last_file )

def session_load_last():
	ts_vim.load_session( __last_file )

def session_save_current():
	ts_vim.save_session( __current_file )
	print 'Current session saved'

def session_load_current():
	ts_vim.load_session( __current_file )
	print 'Current session loaded'

def session_save_prompt():
	file = ts_vim.input('Session name')
	if file:
		ts_vim.save_session(file)
		print 'Session %s saved' % file

def session_load_prompt():
	file = 	ts_vim.input('Session name')
	if file:
		ts_vim.load_session(file)
		print 'Session %s loaded' % file

def session_load_list():
	session_files = ts_vim.get_sessions()
	file_index = ts_vim.input_list('Session name', session_files)
	if file_index == -1:
		return
	file = session_files[file_index]
	if file:
		ts_vim.load_session(file)

if __name__ == '__main__':
	pass
